package com.han.neo4jjava.controller;

import com.han.neo4jjava.core.location.Location;
import com.han.neo4jjava.core.location.LocationQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/locations")
public class LocationController {

    private final LocationQueryService locationQueryService;

    @GetMapping()
    public List<Location> list() {
        return locationQueryService.findAll();
    }

    @GetMapping("/{id}")
    public Location list(@PathVariable Long id) {
        return locationQueryService.findById(id);
    }

}
